require "drb/drb"

class ServerOne
  def initialize
    @object=Job.new
  end
  
  def get
    @object
  end
end

class ServerTwo
  def retrieve
    drb = DRb::DRbObject.new(nil, "druby://localhost:11123")
    @object = drb.get
    drb = nil
  end
  
  def process
    puts @object.name
    puts @object.inspect
  end
  
  def get
    @object
  end
end

class Job
  include DRbUndumped
  def name
    "job name"
  end
end


uri1 = "druby://localhost:11123"
uri2 = "druby://localhost:11124"

Thread.new do
  server1obj = ServerOne.new
  server2obj = ServerTwo.new
  
  server1 = DRb::DRbServer.new(uri1, server1obj)
  server2 = DRb::DRbServer.new(uri2, server2obj)
end

client1 = DRb::DRbObject.new(nil, uri1)
client2 = DRb::DRbObject.new(nil, uri2)

client2.retrieve
puts client1.get.inspect
client1 = DRb::DRbObject.new(nil, uri1)
client2.process
puts client2.get